//
//  HomeTopTransactionView.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/4.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "HomeTopTransactionView.h"


@interface HomeTopTransactionView ()


@property (nonatomic, weak)UIImageView * logoImage;

@property (nonatomic, weak)UILabel * explationLabel;

@property (nonatomic, weak)UIButton * setUpButton;

@property (nonatomic, weak)UIButton * loginButton;


@end

@implementation HomeTopTransactionView


- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    UIImageView * logoImage = [[UIImageView alloc] init];
    
//    logoImage.backgroundColor = [UIColor whiteColor];
    logoImage.image = [UIImage imageNamed:@"图层-0"];
    
    self.logoImage = logoImage;
    
    [self addSubview:self.logoImage];
    
    UILabel * explationLabel = [UILabel new];
    
    explationLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    explationLabel.textColor = ColorWithRGB(0xd3d3d3);
    explationLabel.text = @"交易请先";
    
    self.explationLabel = explationLabel;
    
    [self addSubview:self.explationLabel];
    
    
    UIButton * loginButton = [[UIButton alloc] init];
    
//    [loginButton setImage:[UIImage imageNamed:@"登录按钮"] forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(didLoginButton:) forControlEvents:UIControlEventTouchUpInside];
    [loginButton setBackgroundImage:[UIImage imageNamed:@"登录按钮"] forState:UIControlStateNormal];
    
    self.loginButton = loginButton;
    
    [self addSubview:self.loginButton];
    
    
    UIButton * setUpButton = [[UIButton alloc] init];
    
//    [setUpButton setImage:[UIImage imageNamed:@"注册按钮"] forState:UIControlStateNormal];
    [setUpButton addTarget:self action:@selector(didLoginButton:) forControlEvents:UIControlEventTouchUpInside];
    [setUpButton setBackgroundImage:[UIImage imageNamed:@"注册按钮"] forState:UIControlStateNormal];
    
    self.setUpButton = setUpButton;
    
    [self addSubview:self.setUpButton];
    
}



- (void)layoutSubviews{
    
    [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(75 * SCREENH6);
        make.leading.mas_equalTo(self).offset(25 * SCREENH6);
        make.top.mas_equalTo(10 * SCREENH6);
    }];
    
    
    [self.explationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.logoImage.mas_trailing).offset(10 * SCREENH6);
        make.centerY.mas_equalTo(self.logoImage);
    }];
    
    [self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.explationLabel);
        make.leading.mas_equalTo(self.explationLabel.mas_trailing).offset(13 * SCREENH6);
        make.width.mas_equalTo(80 * SCREENH6);
        make.height.mas_equalTo(42 * SCREENH6);
    }];
    
    [self.setUpButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.loginButton);
        make.leading.mas_equalTo(self.loginButton.mas_trailing).offset(10 * SCREENH6);
        make.width.mas_equalTo(80 * SCREENH6);
        make.height.mas_equalTo(40 * SCREENH6);
    }];
}



- (void)didLoginButton:(UIButton *)button{
    
    NSString * nameStr;
    
    if (button == self.loginButton) {
        nameStr = @"login";
    }else{
        nameStr = @"setup";
    }
    
    [[NSNotificationCenter defaultCenter] postNotificationName:nameStr object:nil];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
